package com.hubstc.book_borrow.service.impl;

import com.hubstc.book_borrow.mapper.ReaderMapper;
import com.hubstc.book_borrow.pojo.Reader;
import com.hubstc.book_borrow.service.ReaderService;
import com.hubstc.book_borrow.utils.JwtUtil;
import com.hubstc.book_borrow.utils.Md5Util;
import com.hubstc.book_borrow.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ReaderServiceImpl implements ReaderService {

    @Autowired
    private ReaderMapper readerMapper;

    @Override
    public Reader findByReaderId(String readerId) {
        Reader r = readerMapper.finByReaderId(readerId);
        return r;
    }

    @Override
    public void register(String readerId, String password, int readerPer) {
        String md5String = Md5Util.getMD5String(password);//密码加密处理
        readerMapper.addReader(readerId, md5String, readerPer);
    }

    @Override
    public void updateReader(Reader reader) {
        readerMapper.updateReader(reader);
    }

    @Override
    public void updatePwd(String newPwd,String readerId) {
        String md5String = Md5Util.getMD5String(newPwd);
        readerMapper.updatePwd(readerId, md5String);
    }


}
